package router

import (
	"github.com/blog/internal/container"
	"github.com/blog/internal/controller"
	"github.com/blog/internal/middleware"
	"github.com/blog/internal/service"
	"github.com/gin-gonic/gin"
)

/*
*
初始化文章相关路由和服务
*/
func InitPostsRouter(Container container.Container, Router *gin.RouterGroup) {
	//数据

	postService := service.NewPostService(Container.GetGormDb())

	controller := controller.NewPostsController(postService)

	//路由
	userRouterPrivate := Router.Group("posts")
	userRouterPrivate.Use(middleware.HandlerAuthWare())

	userRouterPrivate.POST("list", controller.GetList)
	userRouterPrivate.POST("new", controller.AddNewPosts)
	userRouterPrivate.POST("update", controller.UpdatePosts)
	userRouterPrivate.GET("detail", controller.GetPostDetail)
	userRouterPrivate.POST("remove", controller.DeletePosts)

}
